wifi.setmode(wifi.STATION)
wifi.sta.config({ ssid = "admin123", pwd = "12345678" })
wifi.sta.connect()


function boa_rules_post()
    headers = [[
                "content-type: application/json;charset=utf-8\r\n"
    ]]
    data = { title = "port 9000", flag = "0" }
    ok, data_json = pcall(sjson.encode, data)
    if ok then
        http.post("http://10.35.155.30/cgi-bin/rules", headers, data_json, function(status, body)
            if status ~= -1 then
                print(body)
            end
        end)
    end
end

boa_rules_post()

mytmr = tmr.create()
mytmr:alarm(500, tmr.ALARM_AUTO, function ()
    wifi_ip  = wifi.sta.getip()
    if wifi_ip ~= nil then
        print(wifi_ip)
        mytmr:stop()
        boa_rules()
    end
    print("----getip---")
end)
